//
//  WonderfulMeetingFromCollectionViewCell.m
//  Gxj
//
//  Created by 刘伟 on 2017/10/12.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "WonderfulMeetingFromCollectionViewCell.h"

@implementation WonderfulMeetingFromCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self.contentView addSubview:self.shadowAllView];
        [self.shadowAllView addSubview:self.allCellView];
        [self.allCellView addSubview:self.wonderfulImage];                 // 会议图片
        [self.wonderfulImage addSubview:self.industryLab];     // 行业标签
        [self.wonderfulImage addSubview:self.timeLab];         // 时间标签
        [self.wonderfulImage addSubview:self.titleLab];        // 会议标题
        [self.userHeadView addSubview:self.userImage];                      // 用户头像
        [self.allCellView addSubview:self.userName];                       // 用户名称
        [self.allCellView addSubview:self.userProfile];                    // 用户简介
        [self.allCellView addSubview:self.userHeadView];
        [self.allCellView addSubview:self.timeImage];
        [self.allCellView addSubview:self.releaseTime];
        [self showWonderfulMeetingView];
    }
    return self;
}

- (void)showWonderfulMeetingView
{
    _shadowAllView.sd_layout
    .topEqualToView(self.contentView)
    .leftSpaceToView(self.contentView,kWidthScale(15))
    .rightEqualToView(self.contentView)
    .bottomSpaceToView(self.contentView,kHeightScale(10));
    
    _allCellView.sd_layout
    .topEqualToView(self.shadowAllView)
    .leftEqualToView(self.shadowAllView)
    .rightEqualToView(self.shadowAllView)
    .bottomEqualToView(self.shadowAllView);
    
    _wonderfulImage.sd_layout
    .topSpaceToView(self.allCellView,kHeightScale(0))
    .leftSpaceToView(self.allCellView,0)
    .rightSpaceToView(self.allCellView,0)
    .heightIs(kHeightScale(100));
    
    for (int i = 0; i < 2; i++) {
        _industryLab = [[UILabel alloc] initWithFrame:CGRectMake(kWidthScale(5) + kWidthScale(37) * i, kHeightScale(5), kWidthScale(35), kHeightScale(15))];
        
        _industryLab.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        _industryLab.text = @"商业";
        _industryLab.textColor = [UIColor colorWithWhite:0.9 alpha:1];
        _industryLab.font = [UIFont systemFontOfSize:kWidthScale(9)];
        _industryLab.textAlignment = NSTextAlignmentCenter;
        _industryLab.layer.cornerRadius = kWidthScale(5);
        _industryLab.layer.masksToBounds = YES;
        
        [self.wonderfulImage addSubview:self.industryLab];
    }
    
    _timeLab.sd_layout
    .topSpaceToView(self.wonderfulImage,kHeightScale(5))
    .rightSpaceToView(self.wonderfulImage,kWidthScale(5))
    .widthIs(kWidthScale(45))
    .heightIs(kHeightScale(15));
    
    _titleLab.sd_layout
    .bottomSpaceToView(self.wonderfulImage,0)
    .leftEqualToView(self.wonderfulImage)
    .rightEqualToView(self.wonderfulImage)
    .heightIs(kHeightScale(20));
    
    _userHeadView.sd_layout
    .topSpaceToView(self.wonderfulImage,kHeightScale(5))
    .leftSpaceToView(self.allCellView,kWidthScale(10))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    _userImage.sd_layout
    .topSpaceToView(self.userHeadView,kHeightScale(1.5))
    .leftSpaceToView(self.userHeadView,kWidthScale(1.5))
    .rightSpaceToView(self.userHeadView,kWidthScale(1.5))
    .bottomSpaceToView(self.userHeadView,kHeightScale(1.5));
    
    _userName.sd_layout
    .topSpaceToView(self.wonderfulImage,kHeightScale(5))
    .leftSpaceToView(self.userHeadView,kWidthScale(5))
    .widthIs(kWidthScale(100))
    .heightIs(kHeightScale(11));
    
    _timeImage.sd_layout
    .topSpaceToView(self.userName,kHeightScale(5))
    .leftEqualToView(self.userName)
    .widthIs(kWidthScale(11))
    .heightIs(kHeightScale(11));
    
    _releaseTime.sd_layout
    .centerYEqualToView(self.timeImage)
    .leftSpaceToView(self.timeImage,kWidthScale(3))
    .autoHeightRatio(0);
    [_releaseTime setSingleLineAutoResizeWithMaxWidth:kWidthScale(60)];
    
    _userProfile.sd_layout
    .topSpaceToView(self.timeImage,kHeightScale(5))
    .leftEqualToView(self.userHeadView)
    .rightSpaceToView(self.allCellView,kWidthScale(10))
    .heightIs(kHeightScale(11));
}

// 会议图片
- (UIImageView *)wonderfulImage
{
    if (!_wonderfulImage)
    {
        _wonderfulImage = [[UIImageView alloc] init];
        _wonderfulImage.image = [UIImage imageNamed:@"ditu"];
//        _wonderfulImage.layer.cornerRadius = kWidthScale(12);
//        _wonderfulImage.layer.masksToBounds = YES;
    }
    return _wonderfulImage;
}

// 时间标签
- (UILabel *)timeLab
{
    if (!_timeLab)
    {
        _timeLab = [[UILabel alloc] init];
        _timeLab.textAlignment = NSTextAlignmentCenter;
        _timeLab.layer.cornerRadius = 3;
        _timeLab.layer.masksToBounds = YES;
        _timeLab.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        _timeLab.textColor = [UIColor whiteColor];
        _timeLab.font = [UIFont systemFontOfSize:kWidthScale(7)];
        _timeLab.text = @"1小时20分";
    }
    return _timeLab;
}
// 会议标题
- (UILabel *)titleLab
{
    if (!_titleLab)
    {
        _titleLab = [[UILabel alloc] init];
        _titleLab.text = @"梦想";
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        _titleLab.textColor = [UIColor whiteColor];
        _titleLab.font = [UIFont systemFontOfSize:kWidthScale(13)];
    }
    return _titleLab;
}
// 用户头像
- (UIButton *)userImage
{
    if (!_userImage)
    {
        _userImage = [UIButton buttonWithType:UIButtonTypeCustom];
        [_userImage setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:0];
        _userImage.layer.cornerRadius = kWidthScale(12);
        _userImage.layer.masksToBounds = YES;
    }
    return _userImage;
}
// 用户名称
- (UILabel *)userName
{
    if (!_userName)
    {
        _userName = [[UILabel alloc] init];
        _userName.text = @"从不后悔的我";
        _userName.textColor = [UIColor blackColor];
        _userName.textAlignment = NSTextAlignmentLeft;
        _userName.font = [UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _userName;
}
// 用户简介
- (UILabel *)userProfile
{
    if (!_userProfile)
    {
        _userProfile = [[UILabel alloc] init];
        _userProfile.textAlignment = NSTextAlignmentLeft;
        _userProfile.text = @"简介：信仰就是信仰，是对是错也好不必说了，是怨是爱也好不需发表……";
        _userProfile.textColor = [UIColor colorWithHexString:@"#666666"];
        _userProfile.font = [UIFont systemFontOfSize:kWidthScale(11)];
    }
    return _userProfile;
}

- (UIView *)userHeadView
{
    if (!_userHeadView)
    {
        _userHeadView = [[UIView alloc] init];
        _userHeadView.backgroundColor = [UIColor colorWithRed:(213.0/255) green:(213.0/255) blue:(213.0/255) alpha:1];;
        _userHeadView.layer.masksToBounds=YES;
        _userHeadView.layer.cornerRadius= kWidthScale(12.5);
        _userHeadView.layer.shadowColor = [UIColor blackColor].CGColor;
        _userHeadView.layer.shadowOffset = CGSizeMake(-3, 1);
        _userHeadView.layer.shadowOpacity = 0.4;
        _userHeadView.layer.shadowRadius = 2.0;
        _userHeadView.clipsToBounds = NO;
    }
    return _userHeadView;
}

- (UIView *)allCellView
{
    if (!_allCellView)
    {
        _allCellView = [[UIView alloc] init];
        _allCellView.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:251.0/255.0 blue:251.0/255.0 alpha:1];
        _allCellView.layer.cornerRadius = kWidthScale(8);
        _allCellView.layer.masksToBounds = YES;
    }
    return _allCellView;
}

- (UIView *)shadowAllView
{
    if (!_shadowAllView)
    {
        _shadowAllView = [[UIView alloc] init];
        _shadowAllView.layer.shadowColor = [UIColor blackColor].CGColor;
        _shadowAllView.layer.shadowOffset = CGSizeMake(0, 1);
        _shadowAllView.layer.shadowOpacity = 0.5;
        _shadowAllView.clipsToBounds = NO;
    }
    return _shadowAllView;
}
// 时间标签
- (UIImageView *)timeImage
{
    if (!_timeImage)
    {
        _timeImage = [[UIImageView alloc] init];
        _timeImage.image = [UIImage imageNamed:@"cxshijian"];
    }
    return _timeImage;
}
// 发布时间
- (UILabel *)releaseTime
{
    if (!_releaseTime)
    {
        _releaseTime = [[UILabel alloc] init];
        _releaseTime.text = @"8:15";
        _releaseTime.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _releaseTime.textColor = [UIColor colorWithHexString:@"#999999"];
        [_releaseTime updateLayout];
    }
    return _releaseTime;
}

@end
